Django Framework / Templates / Static Files
Static Files
-
Step
1. Create a folder for Django static files
mysite > (New Folder) static
2. Define the Django static URL in the settings
mysite > mysite > settings.py
INSTALLED_APPS = [ 'main.apps.MainConfig', 'django.contrib.staticfiles', ... ] STATIC_URL = '/static/' STATICFILES_DIRS = [ os.path.join(BASE_DIR, "static"), ] 3. store css, js and images files in static folder
4. Load static in the HTML template
mysite > main > templates > main > home.html
5. in html
{% load static %} Title